from typing import List


def findUnsortedSubarray(nums: List[int]) -> int:
    start = 0
    end = 0
    old_nums = nums.copy()
    nums.sort()
    print(nums)
    print(old_nums)

    for i in range(len(nums)):
        if nums[i] != old_nums[i]:
            start = i
    for i in range(len(nums) - 1, -1, -1):
        if nums[i] != old_nums[i]:
            end = i
    if start == 0 and end == 0:
        return 0
    print(start)
    print(end)
    return start - end + 1


print(findUnsortedSubarray([2, 6, 4, 8, 10, 9, 15]))
